<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>作业</title>
		<script type="text/javascript">
			function checkUser(){
				if(username()&&password()){
					return true;
				}
				return false;
			}
			
			function username(){
				var username = document.forms[0].username.value;
				
				for(i = 0; i < username.length;i++){
					z = username.charAt(i);
					if(!(z >='a'&&z <= 'z' || z >= '0'&&z <= '9'|| z >= '_')){
						alert("会员名含非法字符，只能包括a~z、0~9和下划线")
						return false;
					}
				}
				return true;
			}
			
			function password(){
				var password = document.forms[0].password.value;
				if(password.length == 0 ){
					alert("为输入密码请输入密码")
					return false;
				}
				
				
				if(password.length < 6){
					alert("密码为是不能少于6位，请重新输入!")
					return false;
				}
				return true;
			}
			
		</script>
	</head>
	<body>
		<form action="regist.jsp" onsubmit="return checkUser()">
			<table>
				<tr>
					<td>会员名</td>
					<td><input type="username" name="username" id="" value="" /></td>
					<td>(可包含a~z、0~9和下划线)</td>
				</tr>
				<tr>
					<td>密码</td>
					<td><input type="password" name="password" id="" value="" /></td>
					<td>（至少包含6个字符）</td>
				</tr>
				<tr>
					<td></td>
					<td><input type="submit" name="" id="" value="登录" /></td>
					<td><input type="reset" name="" id="" value="重填" /></td>
				</tr>
			</table>
		</form>
	</body>
</html>
